home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Grafik & Text & Film / Quark XTensions / Freeware Xtensions / Quark AppleScript Scripts / Scripts (text only) / Find⁄Change Style Sheets < prev    next >
Text File  |  1994-05-02  |  3KB  |  63 lines

  1. --Copyright 1994 Quark, Inc.   All rights reserved.
  2.  
  3.  
  4. tell application "QuarkXPress™"
  5.     activate
  6.     if exists (document 1) then
  7.         tell document 1
  8.             
  9.             set doesexist to false
  10.             repeat until (doesexist = true)
  11.                 set findSS to text returned of (display dialog "                    Find/Change Style Sheet
  12.                 
  13. Find what:" default answer "Normal" buttons {"Cancel", "Find"} default button "Find")
  14.                 if exists (every paragraph of every story whose name of style sheet = findSS) then
  15.                     set doesexist to true
  16.                 else
  17.                     display dialog "The style sheet “" & findSS & ¬
  18.                         "” has not been applied in this document." buttons "OK" default button 1 with icon caution
  19.                 end if
  20.             end repeat
  21.             
  22.             set stylelist to name of every style spec as list
  23.             set stylecount to count of every item in stylelist
  24.             set a to 1
  25.             set swapSS to text returned of (display dialog "                    Find/Change Style Sheet
  26.                 
  27. Change to:" default answer "Normal" buttons {"Cancel", "Change"} default button "Change")
  28.             repeat until (a > stylecount)
  29.                 set styleitem to item a of stylelist as string
  30.                 if styleitem = swapSS then
  31.                     set a to stylecount + 1
  32.                 else
  33.                     if (a = stylecount) then
  34.                         display dialog "The style sheet “" & swapSS & "” does not exist in this document." buttons "OK" default button 1 with icon caution
  35.                         set swapSS to text returned of (display dialog "                    Find/Change Style Sheet
  36.                 
  37. Change to:" default answer "Normal" buttons {"Cancel", "Change"} default button "Change")
  38.                         set a to 0
  39.                     end if
  40.                 end if
  41.                 set a to a + 1
  42.             end repeat
  43.             
  44.             set x to count of (every paragraph of every story whose name of style sheet = findSS)
  45.             tell (every paragraph of every story whose name of style sheet = findSS)
  46.                 try
  47.                     set style sheet to swapSS
  48.                 on error
  49.                     display dialog "The style sheet “" & swapSS & "” does not exist in this document." buttons "Cancel" default button 1 with icon stop
  50.                 end try
  51.             end tell
  52.             if x > 1 then
  53.                 display dialog "" & x & " instances of the style sheet “" & findSS & "” were found and changed to the style sheet “" & swapSS & ¬
  54.                     "”." buttons "OK" default button "OK" with icon note
  55.             else
  56.                 display dialog "" & x & " instance of the style sheet “" & findSS & "” was found and changed to the style sheet “" & swapSS & ¬
  57.                     "”." buttons "OK" default button "OK" with icon note
  58.             end if
  59.         end tell
  60.     else
  61.         display dialog "Please open a QuarkXPress™ document before running this script." buttons "Cancel" default button 1 with icon stop
  62.     end if
  63. end tell